﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LX.Web.Excel;
using S4Store.Domain.AfterSaleKpi;

namespace S4Store.Domain.AfterSaleReport
{
    public class WMReport: ExportObject
    {

        #region 数据导出
        public override bool? Discriminate(string propertyname)
        {
            if (propertyname == "SBWHL")
            {
                return this.SBWHL >= StandardConfig.设备完好率目标;
            }
            if (propertyname == "GDBFL")
            {
                return this.GDBFL >= StandardConfig.工单报废率目标;
            }
            if (propertyname == "YCXFL")
            {
                return this.YCXFL >= StandardConfig.一次修复率目标;
            }
            if (propertyname == "GSXL")
            {
                return this.GSXL >= StandardConfig.工时效率目标;
            }
            if (propertyname == "SCLYL")
            {
                return this.SCLYL >= StandardConfig.生产利用率目标;
            }
            if (propertyname == "DTJCL")
            {
                return this.DTJCL >= StandardConfig.当天交车率目标;
            }
            if (propertyname == "ZSJCL")
            {
                return this.ZSJCL >= StandardConfig.准时交车率目标;
            }
            return null;
        }
        #endregion


        public int Year { get; set; }
        public int Month { get; set; }
        public int Day { get; set; }
        public MonthStandardConfig StandardConfig { get; set; }
        public List<AfterSaleWorkshopManagerMonthConfig> M { get; set; }
        public List<AfterSaleWorkshopManagerDayInput> D { get; set; }
        public Store Store { get; set; }

        protected bool showlastday = false;
        public virtual void ShowLastDay(bool value)
        {
            showlastday = value;
        }

        [Export("职员姓名")]
        public string EmployName
        {
            get;
            set;
        }

        [Export("接待前台职业资质")]
        public int WorkYear
        {
            get;
            set;
        }

        [Export("部门机师总数")]
        public int BMJSZS
        {
            get
            {
                return M.Sum(o => o.BMJSZS);
            }
        }

        [Export("部门设备工具总数")]
        public int BMSBGJZS
        {
            get
            {
                return M.Sum(o => o.BMGJZS);
            }
        }

        [Export("本月工单总数")]
        public int BYGDZS
        {
            get
            {
                return D.Sum(o => o.BYGDZS);
            }
        }

        [Export("本月累计入厂台次")]
        public int BYLJRCTC
        {
            get
            {
                return D.Sum(o => o.LYLJRCTC);
            }
        }

        [Export("本月已交车总数")]
        public int BYYJCZS
        {
            get
            {
                return D.Sum(o => o.BYYJCZS);
            }
        }

        [Export("技工出勤时间总和")]
        public int JGCQSJZH
        {
            get
            {
                return D.Sum(o => o.JGCQSJZH);
            }
        }

        [Export("部门定额工时累计总数")]
        public int BMDEGSLJZS
        {
            get
            {
                return D.Sum(o => o.BMDEGSLJZS);
            }
        }

        [Export("部门工位总数")]
        public int BMGWZS
        {
            get
            {
                return M.Sum(o => o.BMGWZS);
            }
        }

        [Export("功能完好设备/工具数")]
        public int GNWHSBGJZS
        {
            get
            {
                return D.Sum(o => o.GNWHSBGJZS);
            }
        }

        [Export("无效工单数量")]
        public int WXGDSL
        {
            get
            {
                return D.Sum(o => o.WXGDSL);
            }
        }

        [Export("预计时间前交车总数")]
        public int YJSJQJCZS
        {
            get
            {
                return D.Sum(o => o.YJSJQJCZS);
            }
        }

        [Export("当日入厂当日交车总数")]
        public int DRRCDRJCZS
        {
            get
            {
                return D.Sum(o => o.DRRCDRJCZS);
            }
        }

        [Export("技工实际作业时间总和")]
        public int JGSJZYSJZH
        {
            get
            {
                return D.Sum(o => o.JGSJZYSJZH);
            }
        }

        [Export("部门实际工时累计总数")]
        public int BMSJGSLJZS
        {
            get
            {
                return D.Sum(o => o.BMSJGSLJZS);
            }
        }

        [Export("交车后回厂返修总数")]
        public int JCHHCFXZS
        {
            get
            {
                return D.Sum(o => o.JCHHCFXZS);
            }
        }

        [Export("设备完好率", Format = "{0}%", BackBround = ExcelCellBg.Warning)]
        public decimal SBWHL
        {
            get
            {
                if (BMSBGJZS == 0) return 0;
                return (decimal)GNWHSBGJZS / (decimal)BMSBGJZS*100;
            }
        }

        [Export("人均工位数", BackBround = ExcelCellBg.Warning)]
        public decimal RJGWS
        {
            get
            {
                if (BMGWZS == 0) return 0;
                return (decimal)BMJSZS / (decimal)BMGWZS;
            }
        }

        [Export("工位周转率", BackBround = ExcelCellBg.Warning)]
        public decimal GWZZL
        {
            get
            {
                if (BMGWZS == 0) return 0;
                return (decimal)BYLJRCTC / (decimal)BMGWZS*30;
            }
        }

        [Export("工单报废率", Format = "{0}%", BackBround = ExcelCellBg.Warning)]
        public decimal GDBFL
        {
            get
            {
                if (BYGDZS == 0) return 0;
                return (decimal)WXGDSL / (decimal)BYGDZS * 100;
            }
        }

        [Export("一次修复率", Format = "{0}%", BackBround = ExcelCellBg.Warning)]
        public decimal YCXFL
        {
            get
            {
                if (BYLJRCTC == 0) return 0;
                return (decimal)(BYLJRCTC-JCHHCFXZS) / (decimal)BYLJRCTC * 100;
            }
        }

        [Export("工时效率", Format = "{0}%", BackBround = ExcelCellBg.Warning)]
        public decimal GSXL
        {
            get
            {
                if (BMSJGSLJZS == 0) return 0;
                return (decimal)BMDEGSLJZS / (decimal)BMSJGSLJZS * 100;
            }
        }

        [Export("生产利用率", Format = "{0}%", BackBround=ExcelCellBg.Warning)]
        public decimal SCLYL
        {
            get
            {
                if (JGCQSJZH == 0) return 0;
                return (decimal)JGSJZYSJZH / (decimal)JGCQSJZH * 100;
            }
        }

        [Export("当天交车率", Format = "{0}%", BackBround=ExcelCellBg.Warning)]
        public decimal DTJCL
        {
            get
            {
                if (BYYJCZS == 0) return 0;
                return (decimal)DRRCDRJCZS / (decimal)BYYJCZS * 100;
            }
        }

        [Export("准时交车率", Format = "{0}%", BackBround=ExcelCellBg.Warning)]
        public decimal ZSJCL
        {
            get
            {
                if (BYYJCZS == 0) return 0;
                return (decimal)YJSJQJCZS / (decimal)BYYJCZS * 100;
            }
        }


    }
}
